<template>
	<view class="content">

		<image class="img_header" :src="avatar"></image>

		<view class="u_name">{{nickname || '未获取到用户名'}}</view>

		<view style="display: none;" class="u_name">{{tel || '--'}}</view>

		<view class="menu_div" @click.stop="onUpdate">
			<view class="menu_txt">版本更新</view>
			<view style="display: flex;align-items: center;">
				<view class="menu_txt" style="margin: 0 16rpx 0 0;color: #aaa;">{{getAppInfo().appVersion}}</view>
				<image class="img_arrow" src="/static/ic_right_arrow.png"></image>
			</view>
		</view>

		<view class="divider" />

		<view class="menu_div" @click.stop="onAbout">
			<view class="menu_txt">关于我们</view>
			<image class="img_arrow" src="/static/ic_right_arrow.png"></image>
		</view>

		<view class="divider" />

		<view class="btn_ok" @click.stop="onOk">退出登录</view>

	</view>
</template>

<script>
	import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update'
	import { getUInfo } from '@/util/util.js'
	import { getAppInfo } from '@/util/uni_util.js'
	export default {
		data() {
			return {
				nickname: '',
				tel: '',
				avatar: '/static/ic_login_logo.png',
			}
		},

		onLoad() {
			let that = this

			this.nickname = getUInfo().nickname
			this.tel = getUInfo().tel
			// this.avatar = getUInfo().avatar
		},

		methods: {

			onUpdate() {
				// #ifdef APP
				checkUpdate()
				// #endif
				// #ifndef APP
				uni.showToast({ icon: 'none', title: '非App无需进行更新' })
				// #endif
			},

			onAbout() {
				uni.showToast({ icon: 'none', title: '致胜物流' })
			},

			onOk() {
				uni.showModal({
					title: '提示',
					content: '是否退出登录？',
					success: res => {
						if (res.confirm) {
							uni.$emit('onLogout', { msg: 'onLogout' })
							uni.removeStorageSync('userinfo')
							uni.redirectTo({ url: '/pages/login/login' })
						}
					}
				})
			},

			getAppInfo() {
				return getAppInfo()
			}
		}
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.img_header {
		width: 160rpx;
		height: 160rpx;
		margin: 100rpx 0 0 0;
		border-radius: 888rpx;
	}

	.u_name {
		font-size: 30rpx;
		margin: 20rpx 0 0 0;
	}

	.btn_ok {
		background: #6974DD;
		width: 550rpx;
		height: 88rpx;
		line-height: 88rpx;
		color: white;
		text-align: center;
		font-size: 30rpx;
		margin: 60rpx 0 0 0;
		border-radius: 888rpx;
	}

	.menu_div {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 100%;
		height: 110rpx;
		margin: 0rpx 0 0 0;
	}

	.menu_txt {
		font-size: 28rpx;
		margin: 0 0 0 30rpx;
	}

	.img_arrow {
		width: 30rpx;
		height: 30rpx;
		margin: 0 30rpx 0 0;
	}

	.divider {
		width: calc(100% - 60rpx);
		height: 1rpx;
		background-color: rgba(1, 1, 1, 0.12);
		margin: 0 30rpx 0 30rpx;
	}
</style>